require 'libxml'
require 'MarcTools'

rismid="B22750003"
dn ='marc:http://www.loc.gov/MARC21/slim'
xml_document = LibXML::XML::Document.file('/home/stephan/existdb/oai/test5.xml')       
book_xpath = '//marc:record/marc:controlfield[@tag="001"][contains(.,"'+rismid+'")]/..'
nodes=xml_document.find(book_xpath,dn)
old_xml=nodes[0]
   
a={"leader"=>"ndm a22 i 4500",
  "240"=>{1=>{"n"=>["BWV 151"]}, 2=>{"n"=>["BC A 17"]}, 3=>{"a"=>["Ser Trost, mein Jesus kmmt (Kantate)"]}}, 
    "852"=>{1=>{"a"=>["D-B"], "c"=>["Mus.ms.Bach P 1045"]}, }}

     
      
 b=MarcTools::MarcConverter.new
myhash=b.marc_to_hash(old_xml)
myhash=b.moveTag(myhash,"240$n", "240$a")
p myhash
myhash=b.removeTagbyValue(myhash, "700$a", "unbekannt")
#moveTag(a,"240$n", "240$a")
#p a
p myhash


#myhash=b.marc_to_hash(old_xml)
#moveTag(myhash,"240$n", "240$a")
#moveTag(a,"240$n", "240$a")
#p a
newhash=b.hash_to_marc(myhash)
p newhash